package base.application;

import swordfish.test.PersonAV;
import android.app.Application;
import android.util.Log;
import android.widget.Toast;

import com.avos.avoscloud.AVOSCloud;
import com.avos.avoscloud.AVObject;

/*
 * Design with <Single Instance Mode>
 */

/**
 * Application manager.
 * 
 * @author Administrator
 * 
 */
public class BaseApplication extends Application {

	private static final String TAG = BaseApplication.class.getSimpleName();

	private static BaseApplication mInstance;

	public BaseApplication() {
		mInstance = this;
	}

	public static BaseApplication getInstance() {
		return mInstance;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		Log.v(TAG, "onCreate");

		initAvos();

	}

	@Override
	public void onLowMemory() {
		super.onLowMemory();
		Log.w(TAG, "onLowMemory");
	}

	public static void showToast(int res) {
		Toast.makeText(BaseApplication.getInstance().getApplicationContext(), res, Toast.LENGTH_SHORT).show();
	}

	public static void showToast(String res) {
		Toast.makeText(BaseApplication.getInstance().getApplicationContext(), res, Toast.LENGTH_SHORT).show();
	}

	protected void initAvos() {
		AVObject.registerSubclass(PersonAV.class);
		AVOSCloud.initialize(this, "ajr06z56ql3emvvbcph2giqns5xsa0hs8jwnenhgih7by3mm", "c6d1mlk1l46omab7a8copwxucqslco977cnyc6iq8jgfdgtm");
	}

}
